package com.sys.platform.controller;

import cn.hutool.core.bean.BeanUtil;
import com.sys.platform.common.web.controller.BaseController;
import com.sys.platform.common.web.domain.AjaxResult;
import com.sys.platform.entity.DossierDevicePosition;
import com.sys.platform.entity.request.dossierDevicePosition.DossierDevicePositionDTO;
import com.sys.platform.service.IDossierDevicePositionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 档案馆设备位置关联Controller
 *
 * @author yuanfuqiang
 * @date 2024-01-18
 */
@Api(tags = "档案馆设备位置管理")
@RestController
@RequestMapping("/dossierDevice/position")
public class DossierDevicePositionController extends BaseController {

    @Autowired
    private IDossierDevicePositionService dossierDevicePositionService;

    /**
     * 新增档案馆设备位置关联
     */
    @ApiOperation("新增或修改设备位置")
    @PostMapping
    public AjaxResult addOrUpdate(@RequestBody DossierDevicePositionDTO dto) {
        DossierDevicePosition dossierDevicePosition = new DossierDevicePosition();
        BeanUtil.copyProperties(dto, dossierDevicePosition);
        return AjaxResult.success(dossierDevicePositionService.insertDossierDevicePosition(dossierDevicePosition));
    }

    /**
     * 修改档案馆设备位置关联
     */
//    @RequiresPermissions("equipment:position:edit")
//    @ApiOperation("修改设备位置")
//    @Log(title = "档案馆设备位置关联", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody DossierDevicePositionDTO dto) {
//        DossierDevicePosition dossierDevicePosition = new DossierDevicePosition();
//        BeanUtil.copyProperties(dto, dossierDevicePosition);
//        return toAjax(dossierDevicePositionService.updateDossierDevicePosition(dossierDevicePosition));
//    }

    /**
     * 删除档案馆设备位置关联
     */
    @ApiOperation("删除设备位置")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return AjaxResult.success(dossierDevicePositionService.deleteDossierDevicePositionByIds(ids));
    }
}
